#include <unistd.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "Inputs.c"

#define event_open(x)          syscall( 299, x)
#define event_close(x)         syscall( 300, x)
#define event_wait(x)          syscall( 301, x)
#define event_signal(x)        syscall( 302, x)
#define print_event_table()    syscall( 303 )

int main(int argc, char ** argv) {

  int choice = -1;
  int iter = 1;
  int id = -1;
  while (choice != 0) {
    printf("Choices: \n");
    printf("\t1) event_open\n");
    printf("\t2) event_close\n");
    printf("\t3) event_wait\n");
    printf("\t4) event_signal\n");
    printf("\t5) print_event_table\n");
    printf("\t0) Quit\n");
    
    choice = readInt("Enter the test number to run: ");
  
    switch (choice) {

    case 1: ;

      int id = readInt("Enter an ID: ");
      
      if ( event_open(&id) ) {
	perror("event_open");
      }
      printf("\nI opened event number %d\n", id);
      break;
    case 2:
      if ( event_close( readInt("Enter an ID: ") ) ) {
	perror("event_close");
      }
      break;
    case 3:
      if ( event_wait( readInt("Enter an ID: ") ) ) {
	perror("event_wait");
      }
      break;
    case 4:
      if ( event_signal( readInt("Enter an ID: ") ) ) {
	perror("event_signal");
      }
      break;
    case 5:
      if ( print_event_table() ) {
	perror("print_event_table");
      }
      break;
    case 0:
      break;
    default:
      printf("Error: %d is not a valid choice.\n\n", choice);
      break;
    }
  }

  printf("\nHave a nice day!\n");

}
